Example of [NSDictionary getObjects:andKeys:]

Posted by eagle on Stack Overflow See other posts from Stack Overflow or by eagle
Published on 2010-05-24T00:21:12Z Indexed on 2010/05/24 0:31 UTC
Read the original article Hit count: 993

Filed under:
|
|
|

I couldn't find a working example of the method [NSDictionary getObjects:andKeys:] on Google. The only link I could find, doesn't compile. I provided the errors/warnings here in case someone is searching for them.

The documentation says that it returns a C array.

NSDictionary *myDictionary = ...;

id objects[]; // Error: Array size missing in 'objects'
id keys[]; // Error: Array size missing in 'keys'

[myDictionary getObjects:&objects andKeys:&keys];

for (int i = 0; i < count; i++) {
  id obj = objects[i];
  id key = keys[i];
}

.

NSDictionary *myDictionary = ...;

NSInteger count = [myDictionary count];
id objects[count];
id keys[count];
[myDictionary getObjects:&objects andKeys:&keys]; // Warning: Passing argument 1 of 'getObjects:andKeys:' from incompatible pointer type.

for (int i = 0; i < count; i++) {
  id obj = objects[i];
  id key = keys[i];
}

Please provide a working example of this method.

© Stack Overflow or respective owner

Related posts about c

    Related posts about objective-c